/**-----------------------------------------------------------
* Program/Project : HaNoiTower
* Written by : Truong Minh Tan-Nguyen Tan Phuc
* Email : tmtuit@gmail.com,tannguyenphuc@gmail.com
* Created date: 27/11/2011
* Modified by: Nguyen Tan Phuc
* Modified date:
* Version: 1.0
* Description:
---------------------------------------------------------*/
#include <iostream>
#include "screen.h"
#include "windows.h"

using namespace std;
int Tower[3];// Khai bai mang so nguyen 3 tru
// Ham dung de dieu khien mau bang so
void setcolor(unsigned short color)                
{                                                  
    HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hcon,color);
}
/**-----------------------------------------------------------
* Description: Ham ve thap va cac dia 
* Method name: Dung toa do
* Parameters: 
* Return value:
---------------------------------------------------------*/
void DrawTower(int n)
{
	int i,j;
	for (i=0;i<10;i++)
	{
		setcolor(14);
		gotoxy(15,5+i);
		cout<<char(186);
		gotoxy(30,5+i);
		cout<<char(186);
		gotoxy(45,5+i);
		cout<<char(186);
	}
	for (i=0;i<n;i++)
	{
		for (j=0;j<2*i+1;j++)
		{
			gotoxy(15-i+j,15-n+i);
			setcolor((i+5)%15);
			cout<<char(219);
		}
	}
}
/**-----------------------------------------------------------
* Description: Ham mian goi va thuc hien cac ham tren
* Method name: 
* Parameters: 
* Return value:
---------------------------------------------------------*/
int main()
{
	int n;
	cout<<"Nhap so dia: ";
	cin>>n;
	system("cls");
	DrawTower(n);
	gotoxy(1,20);
	system("pause");
	return 0;
}
